home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2 Examples.sit / Raven 1.2 Examples / Quill / Source / Temp.cpp < prev    next >
C/C++ Source or Header  |  1997-01-26  |  2KB  |  87 lines

  1. #include <List.h>
  2. #include <Map.h>
  3. #include <Vector.h>
  4.  
  5.  
  6. #define TEST_VECTOR        1
  7. #define TEST_LIST        0
  8. #define TEST_MAP        0
  9.  
  10.  
  11. #if TEST_VECTOR
  12. null_template
  13. struct iterator_trait <long* const*> {
  14.     typedef ptrdiff_t                   distance_type;
  15.     typedef long* const                value_type;
  16.     typedef random_access_iterator_tag    iterator_category;
  17. };
  18.  
  19.  
  20. typedef vector<long*, allocator<long*> > Container;
  21.  
  22. static Container sContainer;                // 8K x 5 = 40K
  23. #endif
  24.  
  25.  
  26. #if TEST_LIST
  27. typedef list<long*, allocator<long*> > Container;
  28.  
  29. static Container sContainer;                // 8K x 33 = 264K
  30. #endif
  31.  
  32.  
  33. #if TEST_MAP
  34. typedef map<long, long*, less<long>, allocator<long*> > Container;
  35. typedef pair<const long, long*>                         ContainerEntry;
  36.  
  37. static Container sContainer;                // 27K x 7 = 189K
  38. #endif
  39.  
  40.  
  41. #if TEST_VECTOR || TEST_LIST
  42. static void TestContainer()
  43. {
  44.     long* value = nil;
  45.     
  46.     Container::iterator iter = sContainer.begin();
  47.     while (iter != sContainer.end()) {
  48.         value = *iter++;
  49.     }
  50.     
  51.     Container::const_iterator iter2 = sContainer.begin();
  52.     while (iter2 != sContainer.end()) {
  53.         value = *iter2++;
  54.     }
  55.     
  56.     size_t size = sContainer.size();
  57.     
  58.     sContainer.resize(100);
  59.     
  60.     sContainer.insert(sContainer.begin(), value);
  61.     sContainer.erase(sContainer.begin());
  62. }
  63. #endif
  64.  
  65.  
  66. #if TEST_MAP
  67. static void TestContainer()
  68. {
  69.     ContainerEntry entry;
  70.     
  71.     Container::iterator iter = sContainer.begin();
  72.     while (iter != sContainer.end()) {
  73.         entry = *iter++;
  74.     }
  75.     
  76.     Container::const_iterator iter2 = sContainer.begin();
  77.     while (iter2 != sContainer.end()) {
  78.         entry = *iter2++;
  79.     }
  80.     
  81.     size_t size = sContainer.size();
  82.         
  83.     sContainer.insert(sContainer.begin(), entry);
  84.     sContainer.erase(sContainer.begin());
  85. }
  86. #endif
  87.